package com.example.backend.service;

import com.example.backend.domain.entity.Feedback;
import com.example.backend.repository.FeedbackRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class FeedbackService {
    private final FeedbackRepository feedbackRepository;

    public FeedbackService(FeedbackRepository feedbackRepository) {
        this.feedbackRepository = feedbackRepository;
    }

    public Feedback save(Feedback feedback) {
        return feedbackRepository.save(feedback);
    }

    @Transactional(readOnly = true)
    public Page<Feedback> findByTicket(Long ticketId, Pageable pageable) {
        return feedbackRepository.findByTicket_Id(ticketId, pageable);
    }
}


